<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:f="http://java.sun.com/jsf/core"
  template="/WEB-INF/template/template_nobanner.xhtml">

  <f:metadata>
    <f:event type="preRenderView" listener="#{loginAction.init()}"/>
    <f:event type="preRenderView" listener="#{loginAction.redirectIfOnlySSOEnabled()}"/>
    <f:viewParam name="continue" value="#{userRedirect.encodedUrl}"/>
  </f:metadata>

  <ui:define name="page_title">#{msgs['jsf.Login']}</ui:define>
  <ui:define name="center_content">

    <script type="application/javascript">
      jQuery(document).ready(function () {
        var usernameFieldId = "[id='#{rich:clientId('username')}']";
        jQuery(usernameFieldId).focus()
      })

      /**
       * enforce hash location by appending the hash lication to the current
       * action so that it persists to the redirected URL.
       */
      function onLogin(form) {
        form.action = form.action + window.location.hash;
        return true;
      }
    </script>

    <div class="header__logo-only">
      <h:link outcome="/public/home.xhtml" id="home" tabindex="1">
        <img src="#{request.contextPath}/resources/assets/img/logo/logo.svg" alt="Zanata"/>
      </h:link>
    </div>

    <div class="g--centered">
      <div
        class="g__item #{applicationConfiguration.multiAuth ? 'l--constrain-medium l--constrain-small-m' : 'l--constrain-small'}">
        <div class="l--push-v-1">
          <h:form styleClass="l--push-bottom-0" id="messages">
            <a4j:outputPanel ajaxRendered="true" layout="block" >
              <h:messages globalOnly="true"
                styleClass="list--no-bullets"
                errorClass="message--danger app-error l--push-bottom-half"
                infoClass="message--highlight l--push-bottom-half"
                warnClass="message--warning l--push-bottom-half"
                rendered="#{showGlobalMessages != 'false'}"/>
            </a4j:outputPanel>
          </h:form>
          <div class="g">
            <ui:remove>
              <!--Internal, JAAS and Kerberos Login form-->
            </ui:remove>
            <h:panelGroup layout="block"
              styleClass="l--push-top-half g__item #{applicationConfiguration.multiAuth ? 'w--1-2 w--1-m' : ''}"
              rendered="#{applicationConfiguration.internalAuth or applicationConfiguration.jaasAuth or applicationConfiguration.kerberosAuth}">
              <ui:fragment rendered="#{applicationConfiguration.multiAuth}">
                <h2
                  class="gamma heading--sub">#{msgs['jsf.login.WithZanata.label']}</h2>
              </ui:fragment>
              <ui:fragment rendered="#{applicationConfiguration.kerberosAuth}">
                <p class="txt--meta">
                  <h:outputText escape="false"
                    value="#{msgs['jsf.auth.KerberosNotice.label']}">
                  </h:outputText>
                </p>
              </ui:fragment>

              <h:form id="loginForm"
                styleClass="l--push-top-half l--pad-all-1 bg--pop-higher" onsubmit="return onLogin(this)">
                <div class="l--clearfix">
                  <h:outputLabel for="username"
                    styleClass="l--float-left">#{msgs['jsf.UsernameOrEmail.placeholder']}</h:outputLabel>
                </div>
                <h:inputText id="username" value="#{loginAction.username}"
                  tabindex="2"/>

                <div class="l--push-top-half l--clearfix">
                  <h:outputLabel for="password"
                    styleClass="l--float-left">#{msgs['jsf.Password']}</h:outputLabel>
                  <span class="txt--meta l--float-right">
                    <h:link outcome="/account/password_reset_request.xhtml"
                      tabindex="4"
                      rendered="#{applicationConfiguration.internalAuth}">
                      #{msgs['jsf.ForgotYourPassword']}
                    </h:link>
                  </span>
                </div>
                <h:inputSecret id="password" value="#{loginAction.password}"
                  tabindex="3"/>

                <div class="l--push-top-1">
                  <h:commandButton id="loginButton"
                    action="#{loginAction.login}"
                    value="#{msgs['jsf.Login']}"
                    styleClass="button--primary button--full"/>

                  <ui:fragment
                    rendered="#{applicationConfiguration.internalAuth}">
                    <h:panelGroup rendered="#{allowPublicRegistration}"
                      styleClass="txt--align-center txt--align-center-s l--push-top-half">
                      #{msgs['jsf.login.DontHaveAnAccount.label']} <h:link
                      outcome="/account/register.xhtml"
                      value="#{msgs['jsf.SignUp']}"/>
                    </h:panelGroup>
                  </ui:fragment>
                  <ui:fragment
                    rendered="#{not applicationConfiguration.internalAuth and not empty applicationConfiguration.registerPath}">
                    <h:outputLink value="#{applicationConfiguration.registerPath}">
                      <h:outputText value="#{msgs['jsf.Signup']}"/>
                    </h:outputLink>
                  </ui:fragment>
                </div>
              </h:form>
            </h:panelGroup>
            <ui:remove>
              <!-- OpenId Login form-->
            </ui:remove>
            <h:panelGroup layout="block"
              styleClass="l--push-top-half g__item #{applicationConfiguration.multiAuth ? 'w--1-2 w--1-m' : ''}"
              rendered="#{applicationConfiguration.openIdAuth}">
              <h:form>
                <ui:fragment rendered="#{applicationConfiguration.multiAuth}">
                  <h2
                    class="gamma heading--sub">#{msgs['jsf.login.OrLoginUsing.label']}</h2>
                </ui:fragment>
                <ul class="list--no-bullets">
                  <li class="l--push-top-half">
                    <h:commandLink action="#{loginAction.openIdLogin('Fedora')}"
                      styleClass="button--full button--fedora" value="Fedora"/>
                  </li>
                  <li class="l--push-top-half">
                    <h:commandLink action="#{loginAction.openIdLogin('Yahoo')}"
                      styleClass="button--full button--yahoo" value="Yahoo"/>
                  </li>
                  <li
                    class="l--push-top-half l--pad-top-half l--pad-h-half bg--pop-higher">
                    <h:outputLabel for="openid">Open ID</h:outputLabel>

                    <div class="g--tighter">
                      <div class="g__item w--3-4 w--3-4-s">
                        <h:inputText id="openid" value="#{loginAction.openId}"/>
                      </div>
                      <div class="g__item w--1-4 w--1-4-s">
                        <h:commandButton
                          action="#{loginAction.openIdLogin('Generic')}"
                          styleClass="button--full" value="Go"/>
                      </div>
                    </div>
                  </li>
                </ul>
              </h:form>
            </h:panelGroup>
            <ui:remove>
              <!-- SAML2 Login -->
            </ui:remove>
            <h:panelGroup layout="block"
              styleClass="l--push-top-half g__item #{applicationConfiguration.multiAuth ? 'w--1-2 w--1-m' : ''}"
              rendered="#{saml2Enabled}">
              <ui:fragment rendered="#{applicationConfiguration.multiAuth}">
                <h2
                  class="gamma heading--sub">#{msgs['jsf.login.OrLoginUsing.label']}</h2>
              </ui:fragment>
              <div class="l--push-top-half">
                <h:link outcome="/account/ssologin.xhtml" id="ssoLogin" styleClass="l--pad-v-half l--pad-h-1 button button--primary">
                  Single Sign On
                </h:link>
              </div>
            </h:panelGroup>
          </div>
        </div>
      </div>
    </div>
  </ui:define>
</ui:composition>
